import java.util.Scanner;

public class deletebook implements doOperation{
    @Override
    public void work(booklist bl) {
        System.out.println("请输入你要删除的书名");
        String name;
        Scanner p=new Scanner(System.in);
        name=p.nextLine();
        int pos=0;
        for(int i=0;i<bl.getUsedsize();i++){
            book a=bl.getbook(i);
            if(a.getName().equals(name)){
                if(i==bl.getUsedsize()) {
                    bl.setUsedsize(bl.getUsedsize()-1);
                }
                pos=i;
                break;
            }
        }
        int j=0;
        for(j=pos+1;j<bl.getUsedsize();j++){
            book b=bl.getbook(j);
            bl.setbook(j-1,b);
        }
        bl.setbook(bl.getUsedsize()-1,null);
        bl.setUsedsize(bl.getUsedsize()-1);
        System.out.println("删除成功");
    }
}
